#include <gtest/gtest.h>

#include "algorithm/common/include/sortAlgorithm.h"
#include "algorithm/common/include/utils.h"
#include <algorithm>
#include <chrono>
#include <random>
#include <vector>
using namespace std;
TEST(TestSortAlgorithm, HeadSortSuit) {
    const int N = 10;
    vector<int> nums(N, 0);
    randint(-10, N, nums);
    vector<int> truth = nums;
    heapSort(nums);
    sort(truth.begin(), truth.end());
    for (int i = 0; i < nums.size(); i++) {
        EXPECT_EQ(truth[i], nums[i]);
    }
}

TEST(TestSortAlgorithm1, HeadSortSuit) {
    const int N = 10;
    vector<int> nums = {4, 6, 8, 5, 9};
    vector<int> truth = nums;
    heapSort(nums);
    sort(truth.begin(), truth.end());
    for (int i = 0; i < nums.size(); i++) {
        EXPECT_EQ(truth[i], nums[i]);
    }
}

TEST(TestQuickSort, HeadSortSuit) {
    //    const int N = 8;
    //    int nums[] = {2, 8, 7, 1, 3, 5, 6, 4};
    //    int truth[] = {1, 2, 3, 4, 5, 6, 7, 8};
    //    QuickSort(nums, 0, N - 1);
    //    for (int i = 0; i < N; i++) {
    //        EXPECT_EQ(truth[i], nums[i]);
    //    }
    //
    const int N = 1000;
    vector<int> nums(N, 0);
    randint(-10, N, nums);
    vector<int> truth = nums;
    QuickSort(nums.data(), 0, N - 1);
    sort(truth.begin(), truth.end());
    for (int i = 0; i < nums.size(); i++) {
        EXPECT_EQ(truth[i], nums[i]);
    }
}
